package me.leiusual.sharing.ui.shop.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.view_holder_shop_business.*
import me.leiusual.sharing.api.model.BusinessType
import me.leiusual.sharing.util.extension.setImageUrl

/**
 * author: leiusual
 * create on: 2019-07-30
 * description:
 */
class ShopBusinessViewHolder(
    override val containerView: View,
    private val clickListener: (BusinessType) -> Unit
) : RecyclerView.ViewHolder(containerView), LayoutContainer, View.OnClickListener {

  private lateinit var business: BusinessType

  init {
    containerView.setOnClickListener(this)
  }

  fun bind(business: BusinessType) {
    this.business = business

    image_view.setImageUrl(business.typeImageUrl)
    text_view_name.text = """${business.businessName}（当前级别：${business.curBusinessLevelName}）"""
    text_view_desc.text = business.description
  }

  override fun onClick(v: View?) {
    clickListener(business)
  }
}